package util;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class JsonUtil {
    public static JSONArray formatMapToJsonArray(List<Map<String, String>> list) throws SQLException {
        JSONArray array = new JSONArray();
        for (Map<String, String> aList : list) {
            JSONObject mapOfColValues = new JSONObject();
            Map<String, String> map = aList;
            for (String key : map.keySet()) {
                mapOfColValues.put(key, map.get(key));
            }
            array.add(mapOfColValues);
        }
        return array;
    }
}
